@extends('admin.layouts.master')
@section('css')
<link rel="stylesheet" href="{{asset('assets/icheck/skins/all.css')}}">
<style>
    /*master引入后显示==会员管理*/
    .system_manage{
        background: #393F64;
    }
    /*搜索框所在的区域*/
    .main_header{
        float: left;
        margin-top: 8px;
        width:100%;
        height: 100px;
        line-height: 100px;

    }
    .main_header_search{
        float: left;
        width: 155px;
        position: relative;
    }
    .main_header_search input{
        border-radius:6px;
        width: 215px;
        height: 40px;
        margin-top: 30px;
        border: 0px solid;
    }
    /*.main_header_search input:hover{*/
    /*box-shadow: 0 8px 12px rgba(0,0,0,0.2);*/
    /*}*/

    /*.main_header_search input{*/
    /*padding-left:45px;*/
    /*font-size: 16px;*/
    /*color:#ccc;*/
    /*}*/
    /*================*/
    .main_header_add{
        float: right;
        width: 215px;
        height: 100px;
        line-height: 100px;
        text-align: right;

    }
    .add_box {
        float: right;
        width: 90px;
        height: 40px;
        margin-top: 32px;
        background: #fff;
        line-height: 40px;
        cursor: pointer;
        border-radius: 6px;
        margin-left:17px;
    }
    .add_box:hover{
        box-shadow: 0 8px 12px rgba(0,0,0,0.2);
    }

    .add_box img{
        float:left;
        margin-top:6px;
        margin-left:6px;
        width: 28px;
        height: 28px;
        line-height: 40px;
    }
    .add_box span{
        float: left;
        font-size:18px;
        margin-left: 8px;
        color:  #24a7f6;
    }
    /*======主要内容区=====*/
    .main_form{
        float: left;
        width: 100%;
        height: 783px;
        background: #fff;
        border-radius: 10px;
        box-shadow: 0 8px 12px rgba(0,0,0,0.2);
    }
    .main_formlist{
        margin-top:30px;
    }
    .main_table{
        width: 94%;
        margin: 0 auto;
        border: 1px solid #B1B1B1;
    }
    .main_table tr{
        height: 15px;
        width: 100%;
    }
    .main_table tr th{
        text-align: center;
        line-height: 20px;
        height: 20px;
        font-size: 18px;
    }
    .main_table tr td{
        text-align: center;
    }
    /*======操作中的编辑与删除的样式======*/
    .formlist_handle a{
        font-size:18px;
        text-decoration: none;
    }
    .formlist_handle span{
        font-size:18px;
        cursor: pointer;
    }
    .formlist_edit{
        color: #79C9F7;
    }
    .formlist_destory{
        color: red;
    }

    /*laravel自带的分页样式*/
    .boot_fenye{
        margin: 0 auto;
        margin-top:2px;
        width: 94%;
        height: 55px;
    }
    .boot_page{
        float: right;

    }
    .boot_page_di{
        margin-left: 10px;
        float: left;
        text-align: right;
        font-size: 14px;
        height: 74px;
        line-height: 74px;

    }
    .boot_page_di_span{
        width: 34px;
        height: 34px;
        border: 1px solid #D6D6D1;
    }
    .boot_page_total{
        margin-left: 10px;
        float:left;
        text-align: right;
        font-size: 14px;
        height: 74px;
        line-height: 74px;


    }
    .boot_choose{
        margin-left:20px;
        float:right;
    }

</style>
@endsection
@section('content')
<form id="editForm">
    <div class="main_header clearfix">
        
            <span><a style="color:white;font-size: 18px" href="/admin/user">账号管理</a><span style="color:white;font-size: 18px">&nbsp;&nbsp;>&nbsp;&nbsp;账号编辑</span></span>


        <div class="main_header_add clearfix">
                <button type="submit" class="btn btn-info">保存</button>
        </div>
    </div>
    <div  class="main_form clearfix">
        <div class="main_formlist"  style="padding: 40px">
            <!--            <form id="editForm" style="padding: 40px">-->
            <div class="form-group">
                <label>用户名</label>
                <input name="user_name" type="text" value="{{$user->user_name}}" class="form-control" required>
                <div class="help-block with-errors"></div>
            </div>
            <div class="form-group">
                <label>姓名</label>
                <input name="name" type="text" value="{{$user->name}}" class="form-control" required>
                <div class="help-block with-errors"></div>
            </div>
            <div class="form-group">
                <label>密码</label>
                <input id="password" name="password" type="password" value="{{$user->password}}" class="form-control" required>
                <div class="help-block with-errors"></div>
            </div>
            <div class="form-group">
                <label>确认密码</label>
                <input data-match="#password" name="repassword" type="password" value="{{$user->password}}" class="form-control" required>
                <div class="help-block with-errors"></div>
            </div>
            <div class="form-group">
                <label>用户角色</label>
                <div>
                    @foreach($roles as $role)
                        <div style="float: left;"><input name="roles[]" type="checkbox" value="{{$role->id}}" @if(in_array($role->id,$user->roles->pluck('id')->toArray())) checked @endif>{{$role->name}}&nbsp;&nbsp;</div>
                    @endforeach
                    <div style="clear: both"></div>
                </div>
                <div class="help-block with-errors"></div>
            </div>
            <div class="form-group">
                <label>用户权限</label>
                <div>
                    @foreach($permissions as $permission)
                        <div style="float: left;"><input name="permissions[]" @if(in_array($permission->slug,$user->allPermissions())) checked @endif type="checkbox" value="{{$permission->id}}">{{$permission->name}}&nbsp;&nbsp;</div>
                    @endforeach
                    <div style="clear: both"></div>
                </div>
                <div class="help-block with-errors"></div>
            </div>  
            <div style="padding-bottom:10px" class="form-group">
                <label>备注</label>
                <div>
                    <textarea name="remark" rows="10" value="{{$user->remark or ''}}" style="width: 100%"></textarea>
                </div>
            </div>
            <!--            </form>-->
        </div>
    </div>
</form>

@endsection
@section('js')
<script src="{{asset('assets/icheck/icheck.min.js')}}"></script>
<script>
    $('input').iCheck({
        checkboxClass: 'icheckbox_flat-blue',
        radioClass: 'iradio_flat-blue'
    });
    $('#editForm').validator().on('submit', function (e) {
        if (!e.isDefaultPrevented()) {
            layer.load(1, {shade: [0.1, '#fff']});
            $.ajax({
                url: "/admin/user/"+{{$user->id}},
                type: 'put',
                dataType: "json",
                data: $("#editForm").serialize(),
                success: function (res) {
                    layer.closeAll();
                    if (res.status == 1) {
                        layer.msg(res.msg, {icon: 1});
                        location.href = "/admin/user";
                    } else {
                        layer.msg(res.msg, {icon: 5});
                    }
                }
            });
        }
        return false;
    })
</script>
@endsection


